package com.ppz.Service.impl;


import com.ppz.Service.UserService;
import com.ppz.dao.User;
import com.ppz.mapper.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userMapper;

    /**
     * 用户登录
     * @param phone
     * @param password
     * @return
     */
    @Override
    public User loginUser(String phone, String password) {
        return userMapper.loginUser(phone,password);
    }

    /**
     * 判断手机号是否存在
     * @param phone
     * @return
     */
    @Override
    public User isexistUser(String phone) {
        return userMapper.isExistUser(phone);
    }

    /**
     * 用户添加
     * @param user
     */
    @Override
    public void addUser(User user) {
        User ur =new User();
        ur.setPhone(user.getPhone());
        ur.setPassword(user.getPassword());
        ur.setUsername(user.getUsername());
        ur.setAge(user.getAge());
        ur.setRemark(user.getRemark());
        userMapper.addUser(ur);

    }
    /**
     * 用户修改
     * @param user
     */
    @Override
    public void updateUser(User user) {
        User ur =new User();
        ur.setPhone(user.getPhone());
        ur.setPassword(user.getPassword());
        ur.setUsername(user.getUsername());
        ur.setAge(user.getAge());
        ur.setRemark(user.getRemark());
        userMapper.addUser(ur);
    }
    /**
     * 获取用户信息
     * @param phone
     * @return
     */
    @Override
    public User getUserByPhone(String phone) {
        return userMapper.getUserByPhone(phone);
    }

    /**
     * 删除用户信息
     *
     * @param phone
     */
    @Override
    public boolean deleteUserByPhone(String phone) {
       return userMapper.deleteUserByPhone(phone);
    }


}
